package com.ray.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class PoolTest {

    public static void main(String[] args) {

//        MyThead myThead = new MyThead();
//        Thread thread = new Thread(myThead);
//        thread.start();

        //创建线程池  newFixedThreadPool线程池大小
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        //放入线程
        executorService.execute(new MyThead());
        executorService.execute(new MyThead());
        executorService.execute(new MyThead());

        //关闭连接
        executorService.shutdown();
    }

}


class MyThead implements Runnable{

    public void run() {
        System.out.println(Thread.currentThread().getName());
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Thread.currentThread().getName()+i);
//        }
    }
}
